import React from "react";
import {Image} from "antd";
import FileApi, {FileObj} from "@/api/web/FileApi.ts";
import {ViewProcessor} from "@/components/FilePreviewProcess/processors/_index.ts";

const _main = ({fileObj}: { fileObj: FileObj }) => {
    return (
        <Image
            src={FileApi.getFileLink(fileObj.path)}
            alt="图片预览"
        />
    )
}

export default class ImageView extends ViewProcessor {
    ViewFunctionComponent = () => <_main fileObj={this.fileObj}/>

    getName = () => "图片"

    isViewAble = () => {
        return !!(this.fileObj.contentType && this.fileObj.contentType.startsWith("image"));
    }

    protected uniKey: string = "ImageView";
}
